package liuyuyang.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import liuyuyang.domain.Permission;
import liuyuyang.mapper.PermissionMapper;
import liuyuyang.service.PermissionService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permission> implements PermissionService {
    @Resource
    private PermissionMapper permissionMapper;

    public Boolean add(Permission permission) {
        return permissionMapper.insert(permission) == 1;
    }

    public Boolean del(Integer pid) {
        return permissionMapper.deleteById(pid) == 1;
    }

    public Boolean edit(Permission permission) {
        System.out.println(permission);
        return permissionMapper.updateById(permission) == 1;
    }

    @Override
    public List<Permission> getRolePerm(Integer rid) {
        return permissionMapper.getRolePerm(rid);
    }
}
